<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>

<body>
    <!-- @keyup(键盘事件)是指按键松开，当指定的按键松开就会触发的事件 -->
    <div id="app">
        <!-- :style  v-bind的简写 -->
        <p :style="style">上面的输入框中输入颜色后敲击回车键实现颜色的改变</p>
        <input type="text" placeholder="name" @keyup.13="changeColor()" v-model="color">
        <!-- 按键修饰符 enter回车键 -->
        <input type="text" placeholder="name" @keyup.enter="changeColor()" v-model="color">
    </div>
    <script>
        //创建Vue对象
        let vue = new Vue({
            el: "#app",
            data: {
                style: "color: red;",
                color: ""
            },
            methods: {
                changeColor() {
                    this.style = "color:" + this.color + ";";
                }
            }
        });
    </script>
</body>

</html>